<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="js/jquery-1.11.0.min.js"></script>
</head>
<body>
<form id="form">
    name: <input type="text" id="name" name="name"> <br>
    money: <input type="text" id="money" name="money"> <br>

    <input type="button" value="新增" id="add">
</form>

<script>
    $("#add").click(function (){
        //获取数据
        let name = $("#name").val();
        let money = $("#money").val();

        let params = {
            name:name,
            money:money
        }

        //发送post请求实现更新
        $.ajax({
            url:"/account",
            type:"POST",
            data:JSON.stringify(params),
            contentType:"application/json",
            success:function (r){
                if (r.code == 1000){
                    location.href = "index.html"
                }else{
                    alert(r.msg)
                }
            },
            dataType:"json"
        })
    });
</script>
</body>
</html>